package com.fayuan.nocv.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fayuan.nocv.dao.LineTrendMapper;
import com.fayuan.nocv.entity.LineTrend;
import com.fayuan.nocv.service.LineTrendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

@Service
public class LineTrendServiceImpl extends ServiceImpl<LineTrendMapper, LineTrend> implements LineTrendService {

    @Autowired
    private LineTrendMapper lineTrendMapper;

    @Override
    public Map<String, List<Object>> queryLine() {

        List<LineTrend> lineTrends = lineTrendMapper.dataForWeek();

        List<Integer>confirm = new ArrayList<>();
        List<Integer>isolation = new ArrayList<>();
        List<Integer>cure = new ArrayList<>();
        List<Integer>dead = new ArrayList<>();
        List<Integer>similar = new ArrayList<>();
        for (LineTrend lineTrend : lineTrends) {
            confirm.add(lineTrend.getConfirm());
            isolation.add(lineTrend.getIsolation());
            cure.add(lineTrend.getCure());
            dead.add(lineTrend.getDead());
            similar.add(lineTrend.getSimilar());
        }

        Map resultMap = new HashMap<>();
        resultMap.put("confirm",confirm);
        resultMap.put("isolation",isolation);
        resultMap.put("cure",cure);
        resultMap.put("dead",dead);
        resultMap.put("similar",similar);

        return resultMap;
    }
}
